<script setup>
import * as echarts from 'echarts';
import { onMounted,onBeforeUnmount } from 'vue'
onMounted(() => {

  var chartDom = document.getElementById('turnover');
  var myChart = echarts.init(chartDom);
  var option;

  option = {
  color: ['blue', 'green', 'orange'],
  title: {
    text: ''
  },
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'cross',
      label: {
        backgroundColor: '#6a7985'
      }
    }
  },
  legend: {
    data: ['堂食', '外卖', '自提']
  },
  toolbox: {
    feature: {
      // saveAsImage: {}//下载保存
    }
  },
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  xAxis: [
    {
      type: 'category',
      boundaryGap: false,
      data: ['00:00', '04:00', '08:00', '12:00', '16:00', '20:00', '24:00']
    }
  ],
  yAxis: [
    {
      type: 'value'
    }
  ],
  series: [
    {
      name: '堂食',
      type: 'line',
      stack: 'Total',
      smooth: true,
      lineStyle: {
        width: 0
      },
      showSymbol: false,
      areaStyle: {
        opacity: 0.8,
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'blue'//渐变原始
          },
          {
            offset: 1,
            color: 'blue'//渐变目标
          }
        ])
      },
      emphasis: {
        focus: 'series'
      },
      data: [140.00, 232.00, 101.00, 264.00, 90.00, 340.00, 250.00]
    },
    {
      name: '外卖',
      type: 'line',
      stack: 'Total',
      smooth: true,
      lineStyle: {
        width: 0
      },
      showSymbol: false,
      areaStyle: {
        opacity: 0.8,
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'green'
          },
          {
            offset: 1,
            color: 'green'
          }
        ])
      },
      emphasis: {
        focus: 'series'
      },
      data: [120, 282, 111, 234, 220, 340, 310]
    },
    {
      name: '自提',
      type: 'line',
      stack: 'Total',
      smooth: true,
      lineStyle: {
        width: 0
      },
      showSymbol: false,
      areaStyle: {
        opacity: 0.8,
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'orange'
          },
          {
            offset: 1,
            color: 'orange'
          }
        ])
      },
      emphasis: {
        focus: 'series'
      },
      data: [320, 132, 201, 334, 190, 130, 220]
    },
   

  ]
};

option && myChart.setOption(option);



})
</script>

<template>
  <div id="turnover" style="width: 600px;height:400px;"></div>
</template>



